﻿@using Admin_jiaju.Core.Models;
@*强制规定传过来的类型*@
@model Message

<form class="layui-form" id="frmAdd">
    <!-- 提示：如果你不想用form，你可以换成div等任何一个普通元素 -->
    <div class="layui-form-item">
        <div class="layui-input-block">
            <input type="hidden" name="Id" id="Id" value="@Model.Id" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">留言人名称</label>
        <div class="layui-input-block">
            <input type="text" readonly="readonly" name="Name" id="Name" value="@Model.Name" placeholder="请输入回复内容" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">电话</label>
        <div class="layui-input-block">
            <input type="text" readonly="readonly" name="Tel" id="Tel" value="@Model.Tel" placeholder="请输入回复内容" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">邮箱</label>
        <div class="layui-input-block">
            <input type="text" readonly="readonly" name="Email" id="Email" value="@Model.Email" placeholder="请输入回复内容" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">回复内容</label>
        <div class="layui-input-block">
            <input type="text" name="Cont" id="Cont" value="@Model.Cont" placeholder="请输入回复内容" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn" lay-submit lay-filter="*">修改</button>
        </div>
    </div>
</form>
@section Scripts{
    <script>
        layui.use(['form', 'layer'], function () {
            var form = layui.form; //表单组件
            var $ = layui.$;
            var layer = layui.layer;//弹出层组件


            //监听提交事件sumbmit,*表示那个提交按钮，过滤器名
            form.on('submit(*)', function (data) {
                var str = $("#frmAdd").serialize();//表单序列化
                console.log(str);
                //$.post(地址,向服务器传的参数,回调函数,返回值类型)
                $.post("/Admin/Message/Edit", str, function (re) {
                    parent.layer.msg("回复成功");//parent父窗体
                    parent.layui.$("#btnSearch").click();//调用你窗体中的查询按钮的单击事件实现，数据刷新
                    //当你在iframe页面关闭自身时
                    var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
                    parent.layer.close(index); //再执行关闭
                }, "text");
                return false; //阻止表单跳转。如果需要表单跳转，去掉这段即可。
            });
        });
    </script>
}